package com.example.swagger.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.xnio.Result;

import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * 测试
 *
 * @author zxiaozhou
 * @date 2020-07-06 17:56
 * @since JDK1.8
 */
@Slf4j
@Validated
@RestController
@RequiredArgsConstructor
@Api(tags = "Common", value = "公共", description = "公共接口相关")
@RequestMapping(value = "/test", produces = MediaType.APPLICATION_JSON_VALUE)
public class TestController {
    
    @ApiOperation(value = "上传文件@(v1.0.0)", notes = "上传文件")
    @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public Result<Object> getUpload(@NotNull(message = "上传文件不能为空") @RequestParam(value = "file") MultipartFile file) {
        return null;
    }


    @ApiOperation(value = "下载文件@(v1.1.0)", notes = "下载文件")
    @GetMapping(value = "/download/{fileId}")
    @ApiImplicitParam(paramType = "path", value = "待下载文件id", name = "fileId", required = true)
    public void getDownLoad(@NotEmpty(message = "待下载文件id不能为空") @PathVariable String fileId, HttpServletResponse response) {

    }


    @ApiOperation(value = "根据编码获取数据字典@(v1.0.0,v1.1.0)", notes = "根据编码获取数据字典")
    @GetMapping(value = "/get/dic/by-code")
    @ApiImplicitParam(paramType = "query", value = "字典类型", name = "code", required = true)
    public Result<List<?>> getDicByCode(@NotEmpty(message = "数据字典类型不能为空") String code) {
        return null;
    }

}
